<!doctype html>
<html class="no-js">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="description" content="">
  <meta name="keywords" content="">
  <meta name="viewport"
        content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <title>系统登录</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="Cache-Control" content="no-siteapp"/>
  <link rel="stylesheet" href="/static/assets/css/amazeui.min.css">
  <link rel="stylesheet" href="/static/assets/css/app.css">
    <style>
        html,body{height: 100%;width: 100%;margin:0;padding:0;}
        body{
            background:url(/static/assets/img/bg12.jpg)no-repeat;
            width:100%;
            height:100%;
            background-size:100% 100%;
            position:absolute;
            filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='/static/assets/img/bg5.jpg',sizingMethod='scale');
        }
    </style>
</head>
<body>
<div class="am-g">
	<div class="myapp-login-logo-block">
		<div class="myapp-login-logo-text">
			<div class="myapp-login-logo-text" style="font-size: 30px;">
				{{ information.name }}
				
			</div>
		</div>

		<div class="login-font">
			<i></i><span></span>
		</div>
		<div class="am-u-sm-5 login-am-center">
			<form class="am-form">
				<fieldset>
					<div class="am-form-group">
						<input type="text" class="am-form-field" id="txt_account" placeholder="输入用户名" required/>
					</div>
					<div class="am-form-group">
						<input type="password" class="am-form-field" id="txt_password" placeholder="输入密码" required/>
					</div>
					<p><button type="button" id="login_button" class="am-btn am-btn-default"><span>登录</span></button></p>
				</fieldset>
			</form>
		</div>
	</div>
</div>
<script src="/static/assets/js/jquery.min.js"></script>
<script src="/static/assets/js/amazeui.min.js"></script>
<script src="/static/assets/js/app.js"></script>
<script src="/static/assets/js/jquery.md5.js"></script>
<script src="/static/assets/js/layer.js"></script>
<script type="text/javascript">
$.ajaxSetup({
  data: {csrfmiddlewaretoken: '{{ csrf_token }}' },
});
$("#login_button").click(function(){
    var namea = $.trim($("#txt_account").val());
    var pw = $.trim($("#txt_password").val());
    var passwdb = $.md5(pw);

    if ($("#txt_account").val() == "") {
        $("#txt_account").focus();
        message_layer('请输入用户名。')
    } else if ($("#txt_password").val() == "") {
        $("#txt_password").focus();
        message_layer('请输入登录密码。')
    } else {
    
    $.ajax({
      "url":"/logininfo/",
      "data":{"UName":namea,"password":passwdb,"pw":pw},
      "datatype":"json",
      "type":"post",
      "async":"false"
      }).success(function(data){
        if (data.status == "success") {
            $("#login_button").find('span').html("登录成功，正在跳转...");
            var logintype = data.data[0];
            //var loginflag = data.data[1];
            //var loginname = data.data[2];
            var loginid = data.data[3];
            var loginmd5 = data.data[4];
            window.setTimeout(function() {
                    window.location.href = "/home/?userid="+loginid+"&loginmd5="+loginmd5;
            }, 500);
        } else {
            $("#login_button").removeAttr('disabled').find('span').html("登录");
            message_layer(data.message)
        }
      }).error(function(data){
        message_layer("用户名或密码错误")
      });
    }
});

function message_layer(message){
    layer.msg(message, {
    time: 2000 //2秒关闭（如果不配置，默认是3秒）
  }); 
}

</script>
</body>
</html>